package com.bs.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.bs.service.CompanyInfoService;
import com.utils.BaseAction;

/**
 * 公司介绍 action
 * @author admin
 * 2016-11-27 18:58:53
 */
@Controller
@RequestMapping("/companyInfo")
public class CompanyInfoAction extends BaseAction{

	/**
	 * 
	 */
	private static final long serialVersionUID = -4730360661492358843L;
	
	@Autowired
	private CompanyInfoService companyInfoService;
	
	/**
	 * 初始化
	 * @param req
	 * @param rep
	 * @return
	 */
	@RequestMapping(value="/init.action")
	public String init(HttpServletRequest req, HttpServletResponse rep){
		return "jsp/bs/areaPredict/areaPredict";
	}
	
	/**
	 * 获取断面实时数据
	 * @param req
	 * @param rep
	 */
	@RequestMapping(value = "getTableData.action", method = RequestMethod.POST)
	public void getTableData(HttpServletRequest req, HttpServletResponse rep){
		try {
			Map<String,String> map = new HashMap<String,String>();
			map.put("dateStart", req.getParameter("comName"));
			List<Map<String, Object>> ret = companyInfoService.getData(map);
			jsonOutPut(rep,ret);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 添加
	 * @param req
	 * @param rep
	 */
	@RequestMapping(value = "save.action", method = RequestMethod.POST)
	public void save(HttpServletRequest req, HttpServletResponse rep) {
		try {
			Map<String,String> map = new HashMap<String,String>();
			map.put("", req.getParameter(""));
			companyInfoService.insertData(map);
			basicOutPut(rep, "success");
		} catch (Exception e) {
			e.printStackTrace();
			basicOutPut(rep, "添加限电计划记录失败!");
		}
	}
	
	/**
	 * 添加
	 * @param req
	 * @param rep
	 */
	@RequestMapping(value = "imgUpLoad.action", method = RequestMethod.POST)
	public void imgUpLoad(HttpServletRequest req, HttpServletResponse rep) {
		basicOutPut(rep, "success");
	}
}
